package com.woniuxy.huayoung.controller;

import com.woniuxy.huayoung.entity.*;
import com.woniuxy.huayoung.result.ResponseResult;
import com.woniuxy.huayoung.service.DestinationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Author zhangyong
 * @Date 2021/7/19 0019
 */
@RestController
@RequestMapping("/destination")
public class DestinationController {

    //日志对象
    private static final Logger logger = LoggerFactory.getLogger(DestinationController.class);

    //注入Service对象
    @Resource
    private DestinationService destinationService;


    /*
     * @Description:目的地查询
     * @Author: zhangyong
     * @Date: 2021/7/21 0021
     * @param destination:目的地
     * @return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<Destination>>
     **/
    @GetMapping("/search")
    public ResponseResult<List<Destination>> searchDestination(String destination){
        List<Destination> destinations = destinationService.searchDestination(destination);
        return new ResponseResult<>(200,"查询目的地成功返回",destinations);
    }

    /*
     * @Description:查询目的地所对应的商品
     * @Author: zhangyong
     * @Date: 2021/7/21 0021
     * @param destination:目的地
     * @return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.TravelGoods>>
     **/
    @GetMapping("/findgoods")
    public ResponseResult<List<TravelGoods>> findGoodsByTravelGoods(String destination){
        logger.debug(destination.toString());
        List<TravelGoods> goodsByTravelGoods = destinationService.findGoodsByTravelGoods(destination);
        logger.debug(goodsByTravelGoods.toString());
        return new ResponseResult<>(200,"查询目的地商品返回成功",goodsByTravelGoods);
    }

    /*
     * @Description:查询热门目的地
     * @Author: zhangyong
     * @Date: 2021/7/21 0021
     * @Return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.Destination>>
     **/
    @GetMapping("/hotdestination")
    public ResponseResult<List<Destination>> hotDestination(){
        List<Destination> destinations = destinationService.hotDestination();
        return new ResponseResult<>(200,"查询热门目的地返回成功",destinations);
    }

    /*
     * @Description: 查询所有的月份
     * @Author: zhangyong
     * @Date: 2021/7/22 0022
     * @Return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.Quarter>>
     **/
    @GetMapping("/findallquarter")
    public ResponseResult<List<Quarter>> findAllQuarter(){
        List<Quarter> allQuarter = destinationService.findAllQuarter();
        return new ResponseResult<>(200,"查询所有季节月份返回成功",allQuarter);
    }
    /*
     * @Description:根据月份查询推荐地点
     * @Author: zhangyong
     * @Date: 2021/7/22 0022
     * @param quarter: 对象接id
     * @Return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.Destination>>
     **/
    @GetMapping("/recommendedplace")
    public ResponseResult<List<Destination>> recommendedPlace(Quarter quarter){
        System.out.println(quarter.getId());
        List<Destination> destinations = destinationService.recommendedPlace(quarter);
        return new ResponseResult<>(200,"查询当季推荐地返回成功",destinations);
    }

    /*
     * @Description:查询所有的主题分类
     * @Author: zhangyong
     * @Date: 2021/7/22 0022
     * @Return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.FeaturedThemes>>
     **/
    @GetMapping("/findallthemes")
    public ResponseResult<List<FeaturedThemes>> findAllFeaturedThemes(){
        List<FeaturedThemes> allFeaturedThemes = destinationService.findAllFeaturedThemes();
        return new ResponseResult<>(200,"查询所有主题分类返回成功",allFeaturedThemes);
    }

    /*
     * @Description:查询主题精选
     * @Author: zhangyong
     * @Date: 2021/7/22 0022
     * @param featuredThemes: 主题分类的id
     * @Return: com.woniuxy.huayoung.result.ResponseResult<java.util.List<com.woniuxy.huayoung.entity.ThemesClassification>>
     **/
    @GetMapping("/findthemes")
    public ResponseResult<List<ThemesClassification>> findThemesByFeaturedThemesId(FeaturedThemes featuredThemes){
        List<ThemesClassification> themes = destinationService.findThemesByFeaturedThemesId(featuredThemes);
        return new ResponseResult<>(200,"查询主题精选返回成功",themes);
    }
}
